package com.aw.guiguzi.module.setting.adapter

import com.aw.baselib.util.AwImgUtil
import com.aw.guiguzi.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder

class HelpImgAdapter : BaseQuickAdapter<Int, BaseViewHolder>(R.layout.adapter_setting_help_img) {
    private var mList: MutableList<Int>? = ArrayList()

    init {
        if (mList == null) {
            mList = ArrayList()
        }
    }

    override fun convert(helper: BaseViewHolder, bean: Int) {
        var title = ""
        title = if (helper.layoutPosition < 3) {
            "走势分析"
        } else {
            "投注计算"
        }
        helper.setText(R.id.tv_title, "图例 " + (helper.layoutPosition + 1) + " · " + title)
        AwImgUtil.setImg(mContext, helper.getView(R.id.iv_img), bean)
    }

    fun addAllData(dataList: MutableList<Int>?) {
        mList = dataList
        setNewData(mList)
        notifyDataSetChanged()
    }

    fun clearData() {
        if (mList != null) {
            val startPosition = 0 //hasHeader is 1
            val preSize = mList!!.size
            if (preSize > 0) {
                mList!!.clear()
                notifyItemRangeRemoved(startPosition, preSize)
            }
        }
    }
}